package com.yyjj.zixun.activity;

import android.os.Bundle;

import com.alibaba.android.arouter.facade.annotation.Route;
import com.aries.ui.view.title.TitleBarView;
import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;
import com.vise.xsnow.http.ViseHttp;
import com.vise.xsnow.http.callback.ACallback;
import com.vise.xsnow.http.mode.CacheMode;
import com.yyjj.zixun.R;
import com.yyjj.zixun.ZiXunPath;
import com.yyjj.zixun.adapter.KuaiXunAdapter;
import com.yyjj.zixun.api.Api;
import com.yyjj.zixun.entity.KuaiXunEntity;
import com.yyjj.zixun.entity.QuKLEntity;

import java.util.ArrayList;

import tech.com.commoncore.app.FastManager;
import tech.com.commoncore.base.BaseRefreshLoadActivity;
import tech.com.commoncore.constant.ApiConstant;
import tech.com.commoncore.entity.BaseTResp;

@Route(path = ZiXunPath.KUAIXUN)
public class KuaiXunActivity extends BaseRefreshLoadActivity<KuaiXunEntity> {


    @Override
    public void setTitleBar(TitleBarView titleBar) {
        titleBar.setTitleMainText("实时快讯");
    }

    @Override
    public int getContentLayout() {
        return R.layout.activity_kuai_xun;
    }

    @Override
    public void initView(Bundle savedInstanceState) {

    }

    @Override
    public BaseQuickAdapter<KuaiXunEntity, BaseViewHolder> getAdapter() {
        return new KuaiXunAdapter(R.layout.zixun_item_coin_flash);
    }

    @Override
    public void loadData(int page) {
        ViseHttp.GET(Api.KUAIXUN_URL)
                .baseUrl(ApiConstant.BASE_URL)
                .addParam("symbol", "bnb")
                .setHttpCache(true)
                .cacheMode(CacheMode.FIRST_REMOTE)
                .request(new ACallback<BaseTResp<ArrayList<KuaiXunEntity>>>() {
                    @Override
                    public void onSuccess(BaseTResp<ArrayList<KuaiXunEntity>> data) {
                        if (data.data != null) {
                            FastManager.getInstance().getHttpRequestControl().httpRequestSuccess(getIHttpRequestControl(), data.data, null);
//                            mjiaoYiYuanAdapter.setNewData(data.data);
                        } else {
                            FastManager.getInstance().getHttpRequestControl().httpRequestSuccess(getIHttpRequestControl(), null, null);
                        }

                    }

                    @Override
                    public void onFail(int errCode, String errMsg) {
//                        FastManager.getInstance().getHttpRequestControl().httpRequestSuccess(getIHttpRequestControl(), null, null);
                    }
                });
    }
}
